﻿namespace CSharpPro;

public class Demo6
{
   public static void demo6()
   {
      Console.Write("请输入菱形的行数（应为奇数）：");
      int n = Convert.ToInt32(Console.ReadLine());

      if (n % 2 == 0)
      {
         Console.WriteLine("请输入奇数行数！");
         return;
      }

      int mid = n / 2; 
      for (int i = 0; i <= mid; i++)
      {
         for (int j = 0; j < mid - i; j++)
         {
            Console.Write(" ");
         }
         for (int j = 0; j < 2 * i + 1; j++)
         {
            Console.Write("*");
         }
         Console.WriteLine();
      }

      for (int i = mid - 1; i >= 0; i--)
      {
         for (int j = 0; j < mid - i; j++)
         {
            Console.Write(" ");
         }
         for (int j = 0; j < 2 * i + 1; j++)
         {
            Console.Write("*");
         }
         Console.WriteLine();
      }
   }
}  

